import java.util.Vector;

import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;


public class ModeloTabla implements TableModel{

	  private Vector datos;
	  private Vector observadores;
	  private String columnas[] = new String[] {"Id", "Tipo", "Valor", "Tipo Dato"};
	  public ModeloTabla(Vector datos) {
	    this.datos = datos;
	    observadores = new Vector();
	  }

	  public int getColumnCount() {
	    return columnas.length;
	  }

	  public int getRowCount() {
	    return datos.size();
	  }

	  public boolean isCellEditable(int rowIndex, int columnIndex) {
	    return false;
	  }

	  public Class getColumnClass(int columnIndex) {
	    switch (columnIndex) {
	                    case 0:
	                        return new String().getClass();
	                    case 1:
	                        return new String().getClass();
	                    case 2:
	                        return new String().getClass();
	                    case 3:
	                    	return new String().getClass();
	                }
	               throw new RuntimeException("Invalid column!");
	  }

	  public Object getValueAt(int rowIndex, int columnIndex) {
	    SimbolNode sn = (SimbolNode) datos.get(rowIndex);
	    switch (columnIndex) {
	      case 0:
	        return String.valueOf(rowIndex);
	      case 1:
	        return sn.getId();
	      case 2:
	        return sn.getToken();
	      case 3:
	    	return sn.getTipo();
	    }
	    throw new RuntimeException("Invalid column!");

	  }

	  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
	  }

	  public String getColumnName(int columnIndex) {
	    return columnas[columnIndex];
	  }

	  public void addTableModelListener(TableModelListener l) {
	    observadores.add(l);
	  }

	  public void removeTableModelListener(TableModelListener l) {
	    observadores.remove(l);
	  }
}
